package com.freedom.admin.domain.service.impl;

import cn.hutool.core.lang.Assert;
import com.freedom.admin.domain.repository.PermissionRepository;
import com.freedom.admin.domain.service.PermissionService;
import com.freedom.admin.infrastructure.persistence.pojo.bo.PermissionBO;
import com.freedom.common.framework.exception.ServiceException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class PermissionServiceImpl implements PermissionService {

    private final PermissionRepository permissionRepository;


    @Override
    public void modifyPermission(PermissionBO permissionBO) {
        Boolean result = permissionRepository.modifyPermission(permissionBO);
        Assert.isTrue(result, () -> new ServiceException("修改权限失败"));
    }

    @Override
    public void addPermission(PermissionBO permissionBO) {
        Boolean result = permissionRepository.addPermission(permissionBO);
        Assert.isTrue(result, () -> new ServiceException("新增权限失败"));
    }

    @Override
    public void removeByIds(List<Integer> ids) {
        permissionRepository.removeByIds(ids);
    }
}
